//
//  MessageView.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/8/29.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class MessageView: UIView {

    let nameView = UIView()
    let numberView = UIView()
    let nameLabel = UILabel()
    let nameText = UILabel()
    let numberLabel = UILabel()
    let numberText = UILabel()

    var marqueeView : MarqueeView!
    
    let verifyBtn = UIButton()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        nameView.backgroundColor = UIColor.white
        numberView.backgroundColor = UIColor.white
        
        nameLabel.text = name
        nameLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        
        nameText.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        
        numberLabel.text = idNumber
        numberLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        
        numberText.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        
        verifyBtn.setTitle(verify, for: .normal)
        verifyBtn.setTitleColor(UIColor.white, for: .normal)
        verifyBtn.backgroundColor = UIColor.red
        verifyBtn.titleLabel?.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        verifyBtn.layer.cornerRadius = RATIO_H(maxNum: 20)
        
        
        self.addSubview(nameView)
        self.addSubview(numberView)
        self.addSubview(verifyBtn)
        
        nameView.addSubview(nameLabel)
        nameView.addSubview(nameText)
        
        numberView.addSubview(numberLabel)
        numberView.addSubview(numberText)
        
        nameView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(RATIO_H(maxNum: 40))
            make.left.equalToSuperview()
            make.right.equalToSuperview()
            make.height.equalTo(RATIO_H(maxNum: 50))
        }
        
        nameLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(RATIO(maxNum: 8))
            make.width.greaterThanOrEqualTo(10)
            make.centerY.equalToSuperview()
            make.height.equalTo(RATIO_H(maxNum: 30))
        }
        
        nameText.snp.makeConstraints { (make) in
            make.right.equalTo(RATIO(maxNum: -8))
            make.centerY.equalToSuperview()
            make.width.greaterThanOrEqualTo(10)
            make.height.equalTo(nameLabel)
        }
        
        numberView.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.right.equalToSuperview()
            make.top.equalTo(nameView.snp.bottom).offset(1)
            make.height.equalTo(RATIO_H(maxNum: 50))
        
        }
        
        numberLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(RATIO(maxNum: 8))
            make.centerY.equalToSuperview()
            make.width.greaterThanOrEqualTo(10)
            make.height.equalTo(RATIO_H(maxNum: 30))
        }
        
        numberText.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(RATIO(maxNum: -8))
            make.centerY.equalToSuperview()
            make.width.greaterThanOrEqualTo(10)
            make.height.equalTo(numberText)
        }
        
//        marqueeView.snp.makeConstraints { (make) in
//            make.top.equalTo(numberView.snp.bottom).offset(RATIO_H(maxNum: 20))
//            make.left.equalToSuperview()
//            make.right.equalToSuperview()
//            make.height.equalTo(RATIO_H(maxNum: 40))
//        }
        
        verifyBtn.snp.makeConstraints { (make) in
            make.top.equalTo(numberView.snp.bottom).offset(RATIO_H(maxNum: 80))
            make.left.equalToSuperview().offset(RATIO(maxNum: 20))
            make.right.equalToSuperview().offset(RATIO(maxNum: -20))
            make.height.equalTo(RATIO_H(maxNum: 40))
            
        }
        
        self.layoutIfNeeded()
        
        marqueeView = MarqueeView.init(frame: .init(x: 0, y: numberView.frame.maxY + RATIO_H(maxNum: 20), width: ScreenW, height: RATIO_H(maxNum: 40)))
        self.addSubview(marqueeView)
        
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

    
}
